﻿using Microsoft.Xna.Framework.Input;

namespace Phoenix.Xna.Framework.Input.Keyboards
{
    /// <summary>
    /// Tracks the state of the keyboard.
    /// </summary>
    internal sealed class KeyboardStateManager : InputStateManager<KeyboardState>
    {
        private class NestedSingleton
        {
            internal static readonly KeyboardStateManager Singleton = new KeyboardStateManager();

            static NestedSingleton() { }
        }

        /// <summary>
        /// Gets a singleton instance of the KeyboardStateManager.
        /// </summary>
        public static KeyboardStateManager Instance
        {
            get { return NestedSingleton.Singleton; }
        }

        private KeyboardStateManager()
        {
            CurrentState = Keyboard.GetState();
        }

        #region InputStateManger Members

        /// <summary>
        /// Updates the states for the input device.
        /// </summary>
        public override void Update()
        {
            PreviousState = CurrentState;
            CurrentState = Keyboard.GetState();
            base.Update();
        }

        #endregion
    }
}
